home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / vol6n21.arc / EGAINFO.ASM < prev    next >
Assembly Source File  |  1987-11-17  |  5KB  |  162 lines

  1.  
  2.  
  3.  
  4.  
  5. ;-----------------------------------------------------------------------
  6. ;  EGAINFO is a subroutine designed to be used with compiled or
  7. ;  interpreted BASIC. See the sample programs MAINPROG.BAS and
  8. ;  SUBPROG1.BAS which show you how the routine is implemented in
  9. ;   your programs.
  10. ;
  11. ;  This routine can be used as is for IBM and Microsoft BASIC, whether
  12. ;  compiled or interpreted.
  13. ;
  14. ;  For compiled IBM/MS BASIC, all you have to do
  15. ;  is assemble this code to create EGAINFO.OBJ and then LINK the module
  16. ;  with your program (or include in a user library). Assemble it like this:
  17. ;     MASM EGAINFO;
  18. ;
  19. ;  Then compile and LINK as shown below. If you are using QuickBASIC 1.0 or
  20. ;  either version of IBM's compiler, substitute BASCOM for QB.
  21. ;     QB Yourprog;
  22. ;     LINK Yourprog+EGAINFO;
  23. ;
  24. ;  If you are using Borland's Turbo Basic, you'll need to perform
  25. ;  the following steps:
  26. ;
  27. ;    1. Use the following commands to create a BIN file:
  28. ;         MASM EGAINFO;
  29. ;         LINK EGAINFO;
  30. ;         EXE2BIN EGAINFO EGAINFO.BIN
  31. ;         DEL EGAINFO.EXE
  32. ;    2. In your program, have a line that says:
  33. ;         $include "egainfo.bin"
  34. ;    3. change the following equate to 1:
  35.  
  36. TURBO_BASIC EQU 0
  37.  
  38. ;  Note that it is very important that you use only integer variables when
  39. ;  calling the routine, since other types of variables can cause problems.
  40. ;
  41. ;  The syntax for calling this routine is:
  42. ;
  43. ;      CALL EGAINFO(EGAMODE%,EGACOLUMNS%,EGAROWS%,EGASTATUS%,EGAMEM%)
  44. ;
  45. ;  After calling the routine, check the variable EGASTATUS%. If it
  46. ;  is -1, there is no EGA in the system. If not -1, the variables
  47. ;  contain the following information:
  48. ;
  49. ;    EGAMODE% is the current video mode.
  50. ;    EGACOLUMNS% is the number of columns on the screen, if in text mode.
  51. ;    EGAROWS% is the number of rows on the screen, if in text mode.
  52. ;    EGASTATUS% is 0 if in color mode, 1 if in monochrome mode or
  53. ;             -1 if no EGA is present.
  54. ;    For VGA monitors, 10 is added to 0 or 1. In other words, if
  55. ;             10, VGA in color mode. If 11, VGA in mono mode.
  56. ;    EGAMEM% is the amount of memory on the EGA card in kilobytes.        
  57. ;=======================================================================
  58.  
  59. CODE    SEGMENT PARA PUBLIC 'CODE'
  60.  
  61.     ASSUME CS:CODE,DS:NOTHING,SS:NOTHING,ES:NOTHING
  62. ;-----------------------------------------------------------------------
  63. ;  Equates - substituted literally when assembled
  64. ;-----------------------------------------------------------------------
  65. IF TURBO_BASIC                    ; these are addresses
  66.         EGAMODE     EQU 22        ; relative to the BP
  67.         EGACOLUMNS    EQU 18        ; register.
  68.         EGAROWS        EQU 14
  69.         EGASTATUS    EQU 10
  70.         EGAMEM        EQU 06
  71. ELSE        
  72.         EGAMODE     EQU 14
  73.         EGACOLUMNS    EQU 12
  74.         EGAROWS        EQU 10
  75.         EGASTATUS    EQU 08
  76.         EGAMEM        EQU 06
  77. ENDIF
  78.  
  79. PUBLIC    EGAINFO
  80. EGAINFO PROC FAR
  81.  
  82.         PUSH    BP            ; save this register    
  83.         MOV    BP,SP            ; for addressing variables
  84.  
  85.         PUSH    SI            ; necessary for QB 4
  86.         PUSH    DI            ; necessary for QB 4
  87.         PUSH    ES            ; BIOS changes this
  88.         
  89.         MOV    SI,[BP+EGASTATUS]    ; point to EGASTATUS%
  90.         MOV    WORD PTR [SI],-1    ; Assume no EGA/VGA
  91.  
  92.         MOV    DX,0            ; Assume no VGA
  93.         MOV    AX,1A00H        ; Check for VGA
  94.         INT    10H            ; Call the BIOS
  95.  
  96.         CMP    AL,1AH            ; If still 1AH, no VGA
  97.         JNZ    FIND_EGA        ; No VGA, but maybe EGA
  98.         CMP     BL,7            ; Make sure it's a VGA
  99.         JE    FOUND_VGA        ; If BL=7 or 8, it's a VGA
  100.         CMP    BL,8
  101.         JNE    FIND_EGA         ; if not, try to find EGA
  102. FOUND_VGA:
  103.         MOV    DX,10            ; VGA is present
  104. FIND_EGA:
  105.         MOV    AH,12H            ; service 12h
  106.         MOV    BL,10H            ; get EGA Information
  107.         PUSH    BP            ; some BIOS'es destroy this
  108.         INT    10H            ; call the BIOS routine
  109.         POP     BP            ; retrieve BP pointer
  110.         
  111.         CMP     BL,10H            ; did it change?
  112.         JZ    EGA_EXIT        ; No, leave with -1 status
  113. EGA_FOUND:
  114.         MOV    AL,BH            ; save color/mono setting
  115.         XOR    AH,AH            ; clear high bits of status
  116.         ADD    AX,DX            ; Add VGA status
  117.         MOV    SI,[BP+EGASTATUS]    ; point to variable
  118.         MOV    WORD PTR [SI],AX    ; pass to BASIC
  119.         
  120.         XOR    BH,BH            ; clear high bits
  121.         INC    BX            ; now 1=64K, 2=128K, etc.
  122.         MOV     CX,6            ; multiply by 64
  123.         SHL    BX,CL            ; shift bits to the left.
  124.         MOV    SI,[BP+EGAMEM]        ; point to variable
  125.         MOV    WORD PTR [SI],BX    ; pass to BASIC
  126.  
  127.         MOV    AX,1130H        ; "Get pointer" service
  128.         PUSH    BP            ; this service changes BP
  129.         INT    10H            ; returns number of rows
  130.         POP    BP            ; restore register
  131.         INC    DL            ; returns number rel. to 0
  132.         XOR    DH,DH            ; clear high bits
  133.         MOV    SI,[BP+EGAROWS]        ; point to variable
  134.         MOV    WORD PTR [SI],DX    ; pass to BASIC
  135.  
  136.         PUSH    BP            ; save in case destroyed
  137.         MOV    AH,0FH            ; get video mode
  138.         INT    10H            ; call the BIOS
  139.         POP    BP            ; retrieve register
  140.         
  141.         MOV    BL,AH            ; number of columns
  142.         XOR    BH,BH            ; clear high bits
  143.         MOV    SI,[BP+EGACOLUMNS]    ; point to variable
  144.         MOV    WORD PTR [SI],BX    ; pass to BASIC
  145.         
  146.         XOR    AH,AH            ; clear high bits of mode
  147.         MOV    SI,[BP+EGAMODE]        ; point to variable
  148.         MOV    WORD PTR [SI],AX    ; pass to BASIC
  149. EGA_EXIT:
  150.         POP    ES
  151.         POP    DI            ; for QB 4
  152.         POP    SI            ; for QB 4
  153.         POP    BP            ; restore for BASIC
  154. IF NOT TURBO_BASIC
  155.         RET    10            ; clean up stack and return
  156. ENDIF
  157.         
  158. EGAINFO ENDP
  159. CODE    ENDS
  160. END
  161.  
  162.